package(default_visibility = ["//visibility:public"])

cc_binary(
    name = "shell",
    srcs = ["shell.c"],
    # Disable Bazel's default behavior of linking to `libstdc++` / `libc++`.
    features = ["-default_link_libs"],
    linkopts = select({
        "@platforms//os:windows": [],
        "//conditions:default": ["-lm"],
    }),
    deps = [":sqlite3"],
)

cc_library(
    name = "sqlite3",
    srcs = ["sqlite3.c"],
    hdrs = ["sqlite3.h"],
    includes = ["."],
    # Some Unix platforms have pthread and/or dlopen in separate libraries.
    linkopts = select({
        "@platforms//os:freebsd": ["-lpthread"],
        "@platforms//os:linux": [
            "-lpthread",
            "-ldl",
        ],
        "@platforms//os:netbsd": ["-lpthread"],
        "@platforms//os:openbsd": ["-lpthread"],
        "//conditions:default": [],
    }),
)

cc_library(
    name = "sqlite3ext",
    hdrs = ["sqlite3ext.h"],
)
